package com.mt.roll.report.controller;

import com.mt.roll.core.base.BaseController;
import com.mt.roll.core.constants.CommonConstant;
import com.mt.roll.core.params.EnabledParam;
import com.mt.roll.core.params.IdListParam;
import com.mt.roll.core.params.IdParam;
import com.mt.roll.core.validator.groups.AddGroup;
import com.mt.roll.core.validator.groups.PageGroup;
import com.mt.roll.core.validator.groups.UpdateGroup;
import com.mt.roll.core.vo.IdListVo;
import com.mt.roll.core.vo.IdVo;
import com.mt.roll.core.vo.PageVo;
import com.mt.roll.core.vo.R;
import com.mt.roll.report.params.PrintModelParam;
import com.mt.roll.report.params.PrintModelQueryParam;
import com.mt.roll.report.service.PrintModelService;
import com.mt.roll.report.vo.PrintModelVo;
import com.mt.roll.core.base.BaseController;
import com.mt.roll.core.constants.CommonConstant;
import com.mt.roll.report.service.PrintModelService;
import com.mt.roll.report.vo.PrintModelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.groups.Default;
import java.util.List;

/**
 * @author hy
 * @date 2021/03/06
 * @since 1.0
 */
@RestController
@RequestMapping(CommonConstant.API_MODULE_REPORT + "print-model")
@Slf4j
@Api(value = "标签模板管理", tags = "标签模板管理", hidden = false)
public class PrintModelController extends BaseController {
    @Autowired
    private PrintModelService printModelService;

    @PostMapping(value = "get")
    @ApiOperation(value = "获取标签模板详情")
    private R<PrintModelVo> get(@Validated @RequestBody IdParam idParam) {
        return printModelService.get(idParam);
    }

    @PostMapping(value = "list")
    @ApiOperation(value = "获取xx列表")
    private R<List<PrintModelVo>> list(@Validated({Default.class}) @RequestBody PrintModelQueryParam printModelQueryParam) {
        return printModelService.list(printModelQueryParam);
    }

    @PostMapping(value = "page")
    @ApiOperation(value = "获取分页标签模板")
    private R<PageVo<PrintModelVo>> page(@Validated({PageGroup.class, Default.class}) @RequestBody PrintModelQueryParam printModelQueryParam) {
        return printModelService.page(printModelQueryParam);
    }

    @PostMapping(value = "tree")
    @ApiOperation(value = "获取xx树列表")
    private R<List<PrintModelVo>> tree(@Validated({Default.class}) @RequestBody PrintModelQueryParam printModelQueryParam) {
        return printModelService.tree(printModelQueryParam);
    }

    @PostMapping(value = "add")
    @ApiOperation(value = "新增")
    private R<IdVo> add(@Validated({AddGroup.class, Default.class}) @RequestBody PrintModelParam printModelParam) {
        return printModelService.add(printModelParam);
    }

    @PostMapping(value = "update")
    @ApiOperation(value = "更新")
    private R<IdVo> update(@Validated({UpdateGroup.class, Default.class}) @RequestBody PrintModelParam printModelParam) {
        return printModelService.update(printModelParam);
    }

    @PostMapping(value = "enabled")
    @ApiOperation(value = "启停xx")
    private R<IdVo> enabled(@Validated @RequestBody EnabledParam enabledParam) {
        return printModelService.enabled(enabledParam);
    }

    @PostMapping(value = "delete")
    @ApiOperation(value = "删除标签模板")
    private R<IdVo> delete(@Validated @RequestBody IdParam idParam) {
        return printModelService.delete(idParam);
    }

    @PostMapping(value = "batchDelete")
    @ApiOperation(value = "批量删除xx")
    private R<IdListVo> delete(@Validated @RequestBody IdListParam idListParam) {
        return printModelService.delete(idListParam);
    }

}
